{% extends "special_menu.html" %} {% load i18n %} {% block content %}
{% if "PAYROLL"|filter_config_option %} {% endif %}
{% trans '(最佳尺寸为200×75像素)'%}
{% trans '显示在报表' %}
{% endblock %} {% block getdatalist %} {% endblock %} {% block addjs %} function setImagePreview(){ $("#id_error").empty(); var docObj=document.getElementById("id_fileUpload"); $(docObj).valid(); var docObjButton=document.getElementById("imageLogoButton"); $(docObjButton).valid(); var imgObjPreview=document.getElementById("id_img_logo"); if(docObj.files && docObj.files[0]) { if(docObj.value.match(/.jpg|.png|.bmp/i)) { imgObjPreview.style.display = 'block'; var img = new Image(); img.onload = function () { if(this.width > 200 || this.height > 75){ $("#id_error").attr("style", "display:block"); $("#id_error").html(''); docObj.value = ''; return false; } imgObjPreview.src = this.src; }; if (window.navigator.userAgent.indexOf("Chrome") >= 1 || window.navigator.userAgent.indexOf("Safari") >= 1) { //imgObjPreview.src = window.webkitURL.createObjectURL(docObj.files[0]); img.src = window.webkitURL.createObjectURL(docObj.files[0]); } else { //imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]); img.src = window.URL.createObjectURL(docObj.files[0]); } }else{ $("#id_error").attr("style", "display:block"); $("#id_error").html(''); return false; } } else { //IE下,使用滤镜 docObj.select(); docObj.blur(); var imgSrc = document.selection.createRange().text; if(imgSrc.match(/.jpg|.png|.bmp/i)) { var localImagId = document.getElementById("localImage"); localImagId.style.width = "80px"; localImagId.style.height = "80px"; //图片异常的捕捉,防止用户修改后缀来伪造图片 try { localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)"; localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc; } catch (e) { $("#id_error").attr("style", "display:block"); $("#id_error").html(''); return false; } imgObjPreview.style.display = 'none'; document.selection.empty(); }else{ $("#id_error").attr("style", "display:block"); $("#id_error").html(''); return false; } } return true; } function formValid(){ var email_check = ($("#id_company_email").val()).match("^[a-zA-Z0-9]+([._\\-]*[a-zA-Z0-9])*@([a-zA-Z0-9]+[-a-zA-Z0-9]*[a-zA-Z0-9]+.){1,63}[a-zA-Z0-9]+$"); if($("#id_company_email").val() != '' && email_check == null) { $("#id_error").attr("style", "display:block"); $("#id_error").html(''); return false; } return true; }; function initVal(){ $("#id_error").empty(); $.ajax({ url:"/base/get_company_info/", type:"Get", dataType:"json", async: true, success: function(callback){ if(callback){ var company_info = callback.company_info; if(company_info.show_in_report == 1){ $("#show_report").attr('checked', true); } $("#id_company_name").val(company_info.company_name); $("#id_company_email").val(company_info.company_email); $("#id_phone_num").val(company_info.phone_number); $("#id_company_country").val(company_info.company_country); $("#id_show_in_report").val(company_info.show_in_report); //$("#id_record_type").val(company_info.record_type); $("#id_estd_id").val(company_info.estd_id); $("#id_agent_id").val(company_info.agent_id); $("#id_currency").val(company_info.currency); $("#id_name_pos").val(company_info.name_pos); $("#id_logo_pos").val(company_info.logo_pos); } }, error: function(XMLHttpRequest, textStatus, errorThrown){ $("#id_error").attr("style", "display:block"); $("#id_error").html(''); } }); } function initFunction(){ $('#id_edit_form').validate({ rules:{ //"company_name":{required:true}, }, errorPlacement: function(error, element) { error.appendTo(element.parent()); } }); $("#show_report").click(function(){ if($(this).attr('checked')== true || $(this).attr('checked')== 'checked'){ $("#id_show_in_report").val(1); }else{ $("#id_show_in_report").val(0); } }); $('#id_submit').click(function(){ $("#id_error").empty(); if($("#id_edit_form").valid()){ if(!formValid()){ return ; } $("#id_edit_form").ajaxSubmit({ url:"/base/set_company_info/", type:"POST", dataType:"json", async: true, success:function(callback){ $("#id_error").attr("style", "display:block"); if (callback.ret == 'ok') { $("#id_error").html(''); }else { $("#id_error").html(''); } }, error:function(XMLHttpRequest, textStatus, errorThrown){ $("#id_error").attr("style", "display:block"); $("#id_error").html(''); } }) } }); initVal(); } initFunction(); {% endblock %} {% block add_contents %} {% endblock %}